﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace simWaifu
{
    //
    // Simple debug message window.
    //
    // DebugOut(string)     -> append string without linebreak
    // DebugOutLine(string) -> append string with linebreak
    //
    public partial class FormDebug : Form
    {
        public FormDebug()
        {
            InitializeComponent();
        }
        
        public void Write(string s)
        {
            textBox1.AppendText(s);
        }

        public void WriteLine(string s)
        {
            if (textBox1.Lines.Count() > 500)
            {
                textBox1.Clear();
                Write("Performed flush after 500 lines.");
                Write(Environment.NewLine);
                Write("Check the simWaifuDebug.txt file for the complete debug output of this session.");
                Write(Environment.NewLine);
                Write("It is located at: " + DebugMessageHandler.GetDebugFileName());
                Write(Environment.NewLine);
                Write(Environment.NewLine);
            }
            Write(s);
            Write(Environment.NewLine);
        }

        private void FormDebug_Load(object sender, EventArgs e)
        {
            //WriteLine("FormDebug_Load()");
        }

        private void FormDebug_Closing(object sender, FormClosingEventArgs e)
        {
            DebugMessageHandler.DisconnectFromDebugForm();
        }

        private void clearFormToolStripMenuItem_Click(object sender, EventArgs e)
        {
            textBox1.Clear();
        }

        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            WriteLine("FormDebug_SaveAs(): Not implemented yet.");
            WriteLine("Copy the contents of the text box and paste them into a file.");
        }
    }
}
